<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<button id="btnPost">发送post请求</button>
<button id="btnGet">发送get请求</button>

<script src="./lib/axios.js"></script>
<script>
    document.querySelector('#btnPost').addEventListener('click',async function() {
        // axios.post('url',{post请求体数据})
        const { data: res } = await axios.post('http://www.liulongbin.top:3306/api/post',{ name:'zs',gender: '女' })
        console.log(res)
    })

    document.querySelector('#btnGet').addEventListener('click',async function() {
        /*
        axios.get(url地址,{
        params: {}  // get参数
        })
         */
        const { data : res} = await axios.get('http://www.liulongbin.top:3306/api/post',{
            params: { id: 1 }
        })
        console.log(res)
    })

</script>
</body>
</html>